package com.partsoft.dits.message;

public enum MessageFormat {
	
	XML("工业可扩展标记语言 (Extensible Markup Language)", 0),
	
	JSON("脚本轻量级数据交换格式(JavaScript Object Notation)", 1);
	
	private String title;
	
	private int code;

	private MessageFormat(String title, int code) {
		this.title = title;
		this.code = code;
	}
	
	public String getTitle() {
		return title;
	}
	
	public int getCode() {
		return code;
	}
	
	public static final MessageFormat fromName(String name) {
		for (MessageFormat format : MessageFormat.values()) {
			if (format.name().equalsIgnoreCase(name)) {
				return format;
			}
		}
		return null;
	}
	
	public static final MessageFormat fromCode(int code) {
		for (MessageFormat format : MessageFormat.values()) {
			if (format.getCode() == code) {
				return format;
			}
		}
		return null;
	}
	
}
